<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
    <title>计数器</title>
    <link rel="stylesheet" href="js/index.css"/>
    <script type="text/javascript" src="js/vue.js"></script>
</head>

<body>

<div id="app">

    <div class="input-num">
        <button @click="subNUm">
            -
        </button>
        <p>{{num}}</p>
        <button @click="addNum">
            +
        </button>
    </div>

</div>

<script src="js/vue.js"></script>

</body>
<script>
   new Vue({
        el: "#app",
        data: {
            num: 0
        },
        //更新计数变量
        methods: {
            addNum() {
                this.num++;
            },
            subNUm() {
                this.num--;
            }
        }
    })
</script>

</html>